<?php
require_once 'Junction/Query/Select.php';
require_once 'Test/Mock/Clause.php';

class Test_Junction_Query_Select extends PHPUnit_Framework_TestCase {
	
	public function testBuilder() {
		$query = new Junction_Query_Select();
		$query->bindTable('Users');
		$query->bindColumn('user_id', null);
		$query->bindColumn('email', 'foo@bar.com');
		$query->bindColumn('password', 'aPassword');
		
		$this->assertTrue($query->toSql() == 'SELECT user_id, email, password FROM Users');
		$this->assertTrue($query->getParameters() == array());
		
		$query = new Junction_Query_Select();
		$query->bindTable('Users');
		$query->bindColumn('user_id', null);
		$query->bindColumn('email', 'foo@bar.com');
		$query->bindColumn('password', 'aPassword');
		
		$query->bindClause(new Test_Mock_Clause());

		$this->assertTrue($query->toSql() == 'SELECT user_id, email, password FROM Users WHERE id = ? AND foo = ?');
		$this->assertTrue($query->getParameters() == array(1, 'bar'));
	}
}
?>